import request from '@/utils/request'

/**
 * 新增设备
 * @param {Object} data
 * @returns
 */
export function addDevice(data) {
  return request({
    url: '/machine/machine',
    headers: { repeatSubmit: false },
    method: 'post',
    data
  })
}

/**
 * 修改
 * @param {Object} data
 * @returns
 */
export function updateDevice(data) {
  return request({
    url: '/machine/machine/update',
    method: 'post',
    data
  })
}

/**
 * 设备详情
 * @param {String} id
 * @returns
 */
export function getDeviceDetail(id) {
  return request({
    url: `/machine/machine/${id}`,
    method: 'get'
  })
}

/**
 * 设备管理
 * @param {Object} params
 * @returns
 */
export function getDeviceList(params) {
  return request({
    url: '/machine/machine',
    method: 'get',
    params
  })
}

/**
 * 设备在线统计
 * @param {Object} params
 * @returns
 */
export function getDeviceCount(params) {
  return request({
    url: '/machine/machine/onLine',
    method: 'get',
    params
  })
}

/**
 * 设备禁用
 * @param {String} id
 * @returns
 */
export function disableDevice(id) {
  return request({
    url: `/machine/machine/disabled/${id}`,
    method: 'post'
  })
}

/**
 * 设备日志
 * @param {String} id
 * @returns
 */
export function deviceLog(id) {
  return request({
    url: `/machine/machineLog`,
    method: 'get',
    param: { id }
  })
}

/**
 * 设备apk版本列表
 * @param {Object} params
 * @returns
 */
export function deviceApkVList(params) {
  return request({
    url: `/machine/apkVersion/appList`,
    method: 'get',
    params
  })
}

/**
 * 设备错误信息列表
 * @param {object} params
 * @returns
 */
export function deviceErrorList(params) {
  return request({
    url: `/machine/machineLog`,
    method: 'get',
    params
  })
}

/**
 * 推送App版本
 * @param {Object} data
 * @returns
 */
export function pushApkVerions(data) {
  return request({
    url: `/machine/apkVersion/push`,
    method: 'post',
    data
  })
}
/**
 * 下载设备日志
 * @param {Object} params
 * @returns
 */
export function downloadDeviceLog(params) {
  return request({
    url: `/machine/machineLog/download`,
    method: 'get',
    params
  })
}

/**
 * 查询设备广告列表
 * @param {string} machineId
 * @returns
 */
export function getDeviceAd(machineId) {
  return request({
    url: `/machine/machineAd/adList`,
    method: 'get',
    params: { machineId }
  })
}

/**
 * 查询设备广告推送
 * @param {Object} data
 * @returns
 */
export function pushDeviceAd(data) {
  return request({
    url: `/machine/machineAd`,
    method: 'post',
    data
  })
}

/**
 * 查询设备货道列表
 * @param {String | Number} machineId
 * @returns
 */
export function getDeviceRoadList(machineId) {
  return request({
    url: `/machine/machineRoad/roadList/${machineId}`,
    method: 'get'
  })
}

/**
 * 更改货道库存数据
 * @param {Object} data
 * @returns
 */
export function setDeviceRoadInvent(data) {
  return request({
    url: `/machine/machineRoad/inventory`,
    method: 'post',
    data
  })
}

/**
 * 重启设备
 * @param {String | Number} machineId
 * @returns
 */
export function restartDevice(machineId) {
  return request({
    url: `/machine/machine/restart/${machineId}`,
    method: 'get'
  })
}

/**
 * 设备数据统计
 * @param {Object} params
 * @returns
 */
export function getMachineReport(params) {
  return request({
    url: `/machine/machine/machineAnalysis`,
    method: 'get',
    params
  })
}

// 设备温度分页查询
export function getDeviceTempListApi(params) {
  return request({
    url: '/machine/machineTemp/findPage',
    method: 'get',
    params
  })
}
// 设备温度趋势图
export function getTempTrendListApi(params) {
  console.log('params', params)
  return request({
    url: '/machine/machineTemp/findAll',
    method: 'get',
    params
  })
}
// 设备温度上传频率
export function updateFrequencyApi(data) {
  return request({
    url: '/machine/machineTemp/frequencyReport',
    method: 'post',
    data
  })
}
// 获取温度上传频率
export function getFrequencyApi(params) {
  return request({
    url: '/machine/machineTemp/frequency',
    method: 'get',
    params
  })
}
/**获取摄像头链接 */
export function getSerialNumberApi(params) {
  return request({
    url: `/machine/machine/playback/${params}`,
    method: 'get'
  })
}
/**获取客服列表 */
export function getOnlineListApi(params) {
  return request({
    url: `/operation/mealReplacement/list`,
    method: 'get',
    params
  })
}
